# -*- coding: utf-8 -*-
"""
Created on Tue Feb 19 14:55:43 2013

@author: aponteeduarddo@gmail.com
Copyright Eduardo Aponte 2013.
"""

from mex_binder import binder_py

mx_eyelink_poll_trackers = binder_py('mx_eyelink_poll_trackers')
mx_eyelink_poll_trackers.mx_c.headers = ['<eyelink.h>','"mex.h"']
mx_eyelink_poll_trackers.mx_c.code = '''

INT16 _main( void )
{
    return eyelink_poll_trackers( ); 
}


void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
    mwSize td[2] = {1,1};
    double *status;
    
    /* Verify input arguments. */
    if(nrhs > 0 ) {
        mexErrMsgTxt("Incorrect number of inputs.");
    } else if( nlhs > 1 ) {
        mexErrMsgTxt("Too many output arguments.");
    }
       
    plhs[0] = mxCreateNumericArray( 2, td, mxDOUBLE_CLASS, mxREAL);
    status = mxGetPr(plhs[0]);    
    *status = (double ) _main( );
    
    return;
    
}


'''

mx_eyelink_poll_trackers.mx_c.mdoc = \
'''function [ status ] = mx_eyelink_poll_trackers( )
%MX_eyelink_poll_trackers Asks all non-tracker computers (with EyeLink 
% software running) on the network to send their names and node address.
%
% Returns:
% 0 if successful, otherwise link error.
%
'''
mx_eyelink_poll_trackers.write_c()
mx_eyelink_poll_trackers.write_m()
mx_eyelink_poll_trackers.compile()
mx_eyelink_poll_trackers.write_sh()

